const inquirer = require('inquirer');
const getPromptModules = require('./getPromptModules');
const defaultFeaturesPrompts = require('./defaultFeaturesPrompts');
const Creator = require('./Creator');
const PromptModuleAPI = require('./PromptModuleAPI');

async function createApp(name){
  /** 构建prompts结构 */
  const creator = new Creator();

  /** 注入默认featuresPrompts */
  creator.injectDefaultFeaturesPrompts(defaultFeaturesPrompts(name));

  /** get all module configure */
  const promptModules = getPromptModules();

  /** 获取注入creator的方法 */
  const promptApi = new PromptModuleAPI(creator);

  /** 将各个modules的配置注入到creator中 */
  promptModules.forEach(module => module(promptApi));

  /** 获取最终的prompts */
  const finalPrompts = creator.getFinalPrompts();

  const answers = await inquirer.prompt(finalPrompts);

  const packageJson = {
    name,
    version: `0.1.0`,
    dependencies: {},
    devDependencies: {},
  }

}

module.exports = { createApp, };